﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Kursovaya_Pav.St.Dm
{
    public partial class MainWindow : Form
    {
        public bool IsLogin;
        EnterData form;

       
        public MainWindow()
        {
            InitializeComponent();
            
            AccessUser f = new AccessUser();
           
            if (f.ShowDialog(this) == DialogResult.OK)
            {

                getValPr();
              
            }
        }


        public void getValPr()
        {
            dataGridView1.DataSource = null;
            dataGridView1.DataMember = null;
            dataGridView1.Update();
            dataSet1.Clear();
           
            dataGridView1.Rows.Clear();
            

            //if (dataSet1.Tables.Count > 0) dataSet1.Tables.Remove("Table");
            
            Con_DB cdb = new Con_DB(@"DBdecor.accdb");
            cdb.GetData("select * from ProductS", dataSet1);
            
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.Update();
            dataGridView1.DataSource = dataSet1; 
            dataGridView1.DataMember = dataSet1.Tables[0].TableName;
            dataGridView1.Columns[10].Visible = false;
            //dataGridView1.Width
            
            dataGridView1.Columns[0].Width = dataGridView1.Width * 17 / 100;
            dataGridView1.Columns[1].Width = dataGridView1.Width * 7 / 100;
            dataGridView1.Columns[2].Width = dataGridView1.Width * 10 / 100;
            dataGridView1.Columns[3].Width = dataGridView1.Width * 10 / 100;
            dataGridView1.Columns[4].Width = dataGridView1.Width * 5 / 100;
            dataGridView1.Columns[5].Width = dataGridView1.Width * 6 / 100;
            dataGridView1.Columns[6].Width = dataGridView1.Width * 5 / 100;
            dataGridView1.Columns[7].Width = dataGridView1.Width * 5 / 100;
            dataGridView1.Columns[8].Width = dataGridView1.Width * 5 / 100;
            dataGridView1.Columns[9].Width = dataGridView1.Width * 25 / 100;

            dataGridView1.Update();
            dataGridView1.Refresh();

            

            string tabSp = "ProductS";
            string fieldSp = "Расположение";
            string rasp = "Товар на витрине";
            string rasp2 = "Товар на складе и витрине";
            string rasp1 = "Товар на складе";


            dataGridView2.DataSource = null;
            dataGridView2.DataMember = null;
            dataGridView2.Update();
            dataSet2.Clear();
            dataGridView2.Rows.Clear();
            cdb.GetData("Select * from " + tabSp + " where " + fieldSp + " like '%" + rasp + "%' or " + fieldSp + " like '%" + rasp2 + "%'", dataSet2);
            dataGridView2.AutoGenerateColumns = true;
            dataGridView2.Update();
            dataGridView2.DataSource = dataSet2;
            dataGridView2.DataMember = dataSet2.Tables[0].TableName;
            dataGridView2.Columns[10].Visible = false;
            dataGridView2.Columns[0].Width = dataGridView1.Width * 17 / 100;
            dataGridView2.Columns[1].Width = dataGridView1.Width * 7 / 100;
            dataGridView2.Columns[2].Width = dataGridView1.Width * 10 / 100;
            dataGridView2.Columns[3].Width = dataGridView1.Width * 10 / 100;
            dataGridView2.Columns[4].Width = dataGridView1.Width * 5 / 100;
            dataGridView2.Columns[5].Width = dataGridView1.Width * 6 / 100;
            dataGridView2.Columns[6].Width = dataGridView1.Width * 5 / 100;
            dataGridView2.Columns[7].Width = dataGridView1.Width * 5 / 100;
            dataGridView2.Columns[8].Width = dataGridView1.Width * 5 / 100;
            dataGridView2.Columns[9].Width = dataGridView1.Width * 25 / 100;
            dataGridView2.Update();
            dataGridView2.Refresh();


            dataGridView3.DataSource = null;
            dataGridView3.DataMember = null;
            dataGridView3.Update();
            dataSet3.Clear();
            dataGridView3.Rows.Clear();
            cdb.GetData("Select * from " + tabSp + " where " + fieldSp + " like '%" + rasp1 + "%' or " + fieldSp + " like '%" + rasp2 + "%'", dataSet3);
            dataGridView3.AutoGenerateColumns = true;
            dataGridView3.Update();
            dataGridView3.DataSource = dataSet3;
            dataGridView3.DataMember = dataSet3.Tables[0].TableName;
            dataGridView3.Columns[10].Visible = false;
            dataGridView3.Columns[0].Width = dataGridView1.Width * 17 / 100;
            dataGridView3.Columns[1].Width = dataGridView1.Width * 7 / 100;
            dataGridView3.Columns[2].Width = dataGridView1.Width * 10 / 100;
            dataGridView3.Columns[3].Width = dataGridView1.Width * 10 / 100;
            dataGridView3.Columns[4].Width = dataGridView1.Width * 5 / 100;
            dataGridView3.Columns[5].Width = dataGridView1.Width * 6 / 100;
            dataGridView3.Columns[6].Width = dataGridView1.Width * 5 / 100;
            dataGridView3.Columns[7].Width = dataGridView1.Width * 5 / 100;
            dataGridView3.Columns[8].Width = dataGridView1.Width * 5 / 100;
            dataGridView3.Columns[9].Width = dataGridView1.Width * 25 / 100;
            dataGridView3.Update();
            dataGridView3.Refresh();
            comboBox1.SelectedIndex = comboBox1.Items.IndexOf("Наименование_товара");
        }
       
      
        private void Form2_Load(object sender, EventArgs e)
        {
            
    
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Info f3 = new Info();
            f3.Show();
        }

        private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {

        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            EnterData f4 = new EnterData();
            if (f4.ShowDialog(this) == DialogResult.OK)
            {

                getValPr();
                getValPr();
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            Redaktirovat();

        }
        public void Redaktirovat()
        {
            EnterData f4 = new EnterData();
            DataSet ds = new DataSet();
            Con_DB cdb = new Con_DB(@"DBdecor.accdb");
            cdb.GetData("select * from Productforedit WHERE ID =" + dataGridView1.SelectedRows[0].Cells[10].Value.ToString(), ds);
            f4.idp = ds.Tables[0].Rows[0][0].ToString();
            f4.textBox1.Text = ds.Tables[0].Rows[0][1].ToString();
            f4.textBox2.Text = ds.Tables[0].Rows[0][2].ToString();
            f4.textBox3.Text = ds.Tables[0].Rows[0][5].ToString();
            f4.textBox4.Text = ds.Tables[0].Rows[0][6].ToString();
            f4.textBox5.Text = ds.Tables[0].Rows[0][7].ToString();
            f4.textBox6.Text = ds.Tables[0].Rows[0][8].ToString();
            f4.textBox7.Text = ds.Tables[0].Rows[0][9].ToString();
            f4.domainUpDown2.SelectedIndex = f4.domainUpDown2.Items.IndexOf(ds.Tables[0].Rows[0][4].ToString());

            f4.domainUpDown1.SelectedIndex = f4.domainUpDown1.Items.IndexOf(ds.Tables[0].Rows[0][3].ToString());
            if (ds.Tables[0].Rows[0][10].ToString() == "Товар на складе и витрине")
            {
                f4.checkedListBox1.SetItemChecked(0, true);
                f4.checkedListBox1.SetItemChecked(1, true);
            }
            else if (ds.Tables[0].Rows[0][10].ToString() == "Товар на складе")
            {
                f4.checkedListBox1.SetItemChecked(0, true);
            }
            else if (ds.Tables[0].Rows[0][10].ToString() == "Товар на витрине")
            {
                f4.checkedListBox1.SetItemChecked(1, true);
            }
            if (ds.Tables[0].Rows[0][11].ToString() != "")
            {
                byte[] pic = (byte[])ds.Tables[0].Rows[0][11];
                MemoryStream mem = new MemoryStream(pic);
                f4.pictureBox1.Image = Image.FromStream(mem);
            }

            if (f4.ShowDialog(this) == DialogResult.OK)
            {

                getValPr();
                getValPr();
            }

        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {

            if (dataGridView1.RowCount > 0 && dataGridView1.SelectedRows.Count > 0 && dataSet1.Tables.Count > 0) 
            {
                Con_DB cdb = new Con_DB(@"DBdecor.accdb");
                dataSet4.Clear();
                pictureBox1.Visible = false;
                //cdb.Data_source = @"C:\Users\1\Desktop\Kursovaya\Kursovaya_Pav.St.Dm\Kursovaya_Pav.St.Dm\bin\Debug\DBdecor.accdb";
                cdb.GetData("select Photo from Product WHERE Photo is not null and  ID =" + dataGridView1.SelectedRows[0].Cells[10].Value.ToString(), dataSet4);
                if (dataSet4.Tables[0].Rows.Count > 0)
                {
                    byte[] pic = (byte[])dataSet4.Tables[0].Rows[0][0];
                    MemoryStream mem = new MemoryStream(pic);
                    pictureBox1.Image = Image.FromStream(mem);
                    pictureBox1.Visible = true;
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
                    
        }

       // const string strConnectionString = "data source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;";
        StringFormat strFormat; //Used to format the grid rows.
        ArrayList arrColumnLefts = new ArrayList();//Used to save left coordinates of columns
        ArrayList arrColumnWidths = new ArrayList();//Used to save column widths
        int iCellHeight = 0; //Used to get/set the datagridview cell height
        int iTotalWidth = 0; //
        int iRow = 0;//Used as counter
        bool bFirstPage = false; //Used to check whether we are printing first page
        bool bNewPage = false;// Used to check whether we are printing a new page
        int iHeaderHeight = 0; //Used for the header height
       
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            //Open the print dialog
            PrintDialog printDialog = new PrintDialog();
            printDialog.Document = printDocument1;
            printDialog.UseEXDialog = true;

            //Get the document
            if (DialogResult.OK == printDialog.ShowDialog())
            {
                printDocument1.DocumentName = "Test Page Print";
                printDocument1.Print();
            }
        }



        private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            try
            {
                //Set the left margin
                int iLeftMargin = e.MarginBounds.Left;
                //Set the top margin
                int iTopMargin = e.MarginBounds.Top;
                //Whether more pages have to print or not
                bool bMorePagesToPrint = false;
                int iTmpWidth = 0;

                //For the first page to print set the cell width and header height
                if (bFirstPage)
                {
                    foreach (DataGridViewColumn GridCol in dataGridView1.Columns)
                    {
                        iTmpWidth = (int)(Math.Floor((double)((double)GridCol.Width /
                                       (double)iTotalWidth * (double)iTotalWidth *
                                       ((double)e.MarginBounds.Width / (double)iTotalWidth))));

                        iHeaderHeight = (int)(e.Graphics.MeasureString(GridCol.HeaderText,
                                    GridCol.InheritedStyle.Font, iTmpWidth).Height) + 11;

                        // Save width and height of headres
                        arrColumnLefts.Add(iLeftMargin);
                        arrColumnWidths.Add(iTmpWidth);
                        iLeftMargin += iTmpWidth;
                    }
                }
                //Loop till all the grid rows not get printed
                while (iRow <= dataGridView1.Rows.Count - 1)
                {
                    DataGridViewRow GridRow = dataGridView1.Rows[iRow];
                    //Set the cell height
                    iCellHeight = GridRow.Height + 5;
                    int iCount = 0;
                    //Check whether the current page settings allo more rows to print
                    if (iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top)
                    {
                        bNewPage = true;
                        bFirstPage = false;
                        bMorePagesToPrint = true;
                        break;
                    }
                    else
                    {
                        if (bNewPage)
                        {
                            //Draw Header
                            e.Graphics.DrawString("Список товаров", new Font(dataGridView1.Font, FontStyle.Bold),
                                    Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top -
                                    e.Graphics.MeasureString("Список товаров", new Font(dataGridView1.Font,
                                    FontStyle.Bold), e.MarginBounds.Width).Height - 13);

                            String strDate = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString();
                            //Draw Date
                            e.Graphics.DrawString(strDate, new Font(dataGridView1.Font, FontStyle.Bold),
                                    Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width -
                                    e.Graphics.MeasureString(strDate, new Font(dataGridView1.Font,
                                    FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top -
                                    e.Graphics.MeasureString("Список товаров", new Font(new Font(dataGridView1.Font,
                                    FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 13);

                            //Draw Columns                 
                            iTopMargin = e.MarginBounds.Top;
                            foreach (DataGridViewColumn GridCol in dataGridView1.Columns)
                            {
                                e.Graphics.FillRectangle(new SolidBrush(Color.LightGray),
                                    new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                    (int)arrColumnWidths[iCount], iHeaderHeight));

                                e.Graphics.DrawRectangle(Pens.Black,
                                    new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                    (int)arrColumnWidths[iCount], iHeaderHeight));

                                e.Graphics.DrawString(GridCol.HeaderText, GridCol.InheritedStyle.Font,
                                    new SolidBrush(GridCol.InheritedStyle.ForeColor),
                                    new RectangleF((int)arrColumnLefts[iCount], iTopMargin,
                                    (int)arrColumnWidths[iCount], iHeaderHeight), strFormat);
                                iCount++;
                            }
                            bNewPage = false;
                            iTopMargin += iHeaderHeight;
                        }
                        iCount = 0;
                        //Draw Columns Contents                
                        foreach (DataGridViewCell Cel in GridRow.Cells)
                        {
                            if (Cel.Value != null)
                            {
                                e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font,
                                            new SolidBrush(Cel.InheritedStyle.ForeColor),
                                            new RectangleF((int)arrColumnLefts[iCount], (float)iTopMargin,
                                            (int)arrColumnWidths[iCount], (float)iCellHeight), strFormat);
                            }
                            //Drawing Cells Borders 
                            e.Graphics.DrawRectangle(Pens.Black, new Rectangle((int)arrColumnLefts[iCount],
                                    iTopMargin, (int)arrColumnWidths[iCount], iCellHeight));

                            iCount++;
                        }
                    }
                    iRow++;
                    iTopMargin += iCellHeight;
                }

                //If more lines exist, print another page.
                if (bMorePagesToPrint)
                    e.HasMorePages = true;
                else
                    e.HasMorePages = false;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
          
            
        }

        private void printDocument1_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            try
            {
                strFormat = new StringFormat();
                strFormat.Alignment = StringAlignment.Near;
                strFormat.LineAlignment = StringAlignment.Center;
                strFormat.Trimming = StringTrimming.EllipsisCharacter;

                arrColumnLefts.Clear();
                arrColumnWidths.Clear();
                iCellHeight = 0;
                iRow = 0;
                bFirstPage = true;
                bNewPage = true;

                // Calculating Total Widths
                iTotalWidth = 0;
                foreach (DataGridViewColumn dgvGridCol in dataGridView1.Columns)
                {
                    iTotalWidth += dgvGridCol.Width;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {

          
            
        }

        private void справочникToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Info f3 = new Info();
            f3.Show();
        }

        private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Redaktirovat();
        }

        private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EnterData f4 = new EnterData();
            if (f4.ShowDialog(this) == DialogResult.OK)
            {

                getValPr();
                getValPr();
            }
        }

        private void печатьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Open the print dialog
            PrintDialog printDialog = new PrintDialog();
            printDialog.Document = printDocument1;
            printDialog.UseEXDialog = true;

            //Get the document
            if (DialogResult.OK == printDialog.ShowDialog())
            {
                printDocument1.DocumentName = "Test Page Print";
                printDocument1.Print();
            }
        }

        private void выходToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void найтиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            button4_Click(this, null);
        }

        private void dataGridView2_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView2.RowCount > 0 && dataGridView2.SelectedRows.Count > 0 && dataSet1.Tables.Count > 0)
            {
                Con_DB cdb = new Con_DB(@"DBdecor.accdb");
                dataSet4.Clear();
                pictureBox1.Visible = false;
                //cdb.Data_source = @"C:\Users\1\Desktop\Kursovaya\Kursovaya_Pav.St.Dm\Kursovaya_Pav.St.Dm\bin\Debug\DBdecor.accdb";
                cdb.GetData("select Photo from Product WHERE Photo is not null and  ID =" + dataGridView2.SelectedRows[0].Cells[10].Value.ToString(), dataSet4);
                if (dataSet4.Tables[0].Rows.Count > 0)
                {
                    byte[] pic = (byte[])dataSet4.Tables[0].Rows[0][0];
                    MemoryStream mem = new MemoryStream(pic);
                    pictureBox1.Image = Image.FromStream(mem);
                    pictureBox1.Visible = true;
                }
            }
        }

        private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }

        private void dataGridView3_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView3.RowCount > 0 && dataGridView3.SelectedRows.Count > 0 && dataSet1.Tables.Count > 0)
            {
                Con_DB cdb = new Con_DB(@"DBdecor.accdb");
                dataSet4.Clear();
                pictureBox1.Visible = false;
                //cdb.Data_source = @"C:\Users\1\Desktop\Kursovaya\Kursovaya_Pav.St.Dm\Kursovaya_Pav.St.Dm\bin\Debug\DBdecor.accdb";
                cdb.GetData("select Photo from Product WHERE Photo is not null and  ID =" + dataGridView3.SelectedRows[0].Cells[10].Value.ToString(), dataSet4);
                if (dataSet4.Tables[0].Rows.Count > 0)
                {
                    byte[] pic = (byte[])dataSet4.Tables[0].Rows[0][0];
                    MemoryStream mem = new MemoryStream(pic);
                    pictureBox1.Image = Image.FromStream(mem);
                    pictureBox1.Visible = true;
                }
            }
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Вы действительно желаете удалить запись?", "Вопрос", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                string tabSp = "Product";
                int idrow = 1;
                string idVal="0";

                Con_DB cdb = new Con_DB(@"DBdecor.accdb");
                switch (tabControl1.SelectedIndex)
                {
                    case 0:
                        idrow = dataGridView1.SelectedCells[0].RowIndex;
                        idVal = dataSet1.Tables[0].Rows[idrow][10].ToString();
                       
                        break;
                    case 1:
                        idrow = dataGridView2.SelectedCells[0].RowIndex;
                        idVal = dataSet2.Tables[0].Rows[idrow][10].ToString();
                        
                        break;
                    case 2:
                        idrow = dataGridView3.SelectedCells[0].RowIndex;
                        idVal = dataSet3.Tables[0].Rows[idrow][10].ToString();
                       
                        break;
                }

                if (idVal != "0")
                {
                    cdb.SetData("DELETE FROM " + tabSp + " where ID = " + idVal);
                   
                }
                getValPr();

                getValPr();



            }
        }
    

        private void button4_Click(object sender, EventArgs e)
        {
            
            string fieldSp = comboBox1.SelectedItem.ToString();
            string tabSp = "Country";
            if (textBox2.Text != "")
            {
                Con_DB cdb = new Con_DB(@"DBdecor.accdb");
                switch (tabControl1.SelectedIndex)
                {
                    case 0:
                        tabSp = "ProductS";
                        fieldSp = comboBox1.SelectedItem.ToString();
                        dataSet1.Clear();
                        
                        cdb.GetData("Select * from " + tabSp + " where " + fieldSp + " like '%" + textBox2.Text + "%'", dataSet1);
                       
                        
                        break;
                    case 1:
                        tabSp = "ProductS";
                        fieldSp = comboBox1.SelectedItem.ToString();
                        dataSet2.Clear();
                        
                        cdb.GetData("Select * from " + tabSp + " where " + fieldSp + " like '%" + textBox2.Text + "%'", dataSet2);
                        
                        break;
                    case 2:
                        tabSp = "ProductS";
                        fieldSp = comboBox1.SelectedItem.ToString();
                        dataSet3.Clear();
                        
                        cdb.GetData("Select * from " + tabSp + " where " + fieldSp + " like '%" + textBox2.Text + "%'", dataSet3);
                        break;
                }
            }
        }

        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            getValPr();
        }

        private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStripButton6_Click(this, null);
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            button4_Click(this, null);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void информацияОбАвтореToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Programmers f5 = new Programmers();
            f5.Show();
        }

        private void обновитьТаблицуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            getValPr();
        }

        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            switch (tabControl1.SelectedIndex)
            {
                case 0:
                    for (int i = 0; i < dataGridView1.ColumnCount; i++)
                    {
                        dataGridView1[i, dataGridView1.SelectedCells[0].RowIndex].Style.BackColor = Color.Orange;
                    }

                    break;
                case 1:
                    for (int i = 0; i < dataGridView1.ColumnCount; i++)
                    {
                        dataGridView2[i, dataGridView2.SelectedCells[0].RowIndex].Style.BackColor = Color.Orange;
                    }
                    break;
                case 2:
                    for (int i = 0; i < dataGridView1.ColumnCount; i++)
                    {
                        dataGridView3[i, dataGridView3.SelectedCells[0].RowIndex].Style.BackColor = Color.Orange;
                    }
                    break;
            }
           
        }

        private void закраситьСтрокуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStripButton8_Click(this, null);
        
        }

        private void помощьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Process.Start(@"Пояснительная записка.pdf");
            }
            catch
            {
                MessageBox.Show("Файл не найден", "Ошибка");
            }
        }
   

        }
      
       
    }

